import App from './App'

// #ifndef VUE3
import Vue from 'vue'
import store from './store'
Vue.config.productionTip = false
App.mpType = 'app'
import api from '@/uni_modules/vmeitime-http/'
import api_common from '@/uni_modules/http-common/'
Vue.prototype.$store = store
Vue.prototype.$api = api
Vue.prototype.$api_common = api_common
import dropdown from '@/components/dt-dropdown/dt-dropdown.vue' 
Vue.component('dropdown', dropdown)
const app = new Vue({
    ...App
})
app.$mount()
Vue.filter('dateFormatYear', function(originVal) {
	const dt = new Date(originVal.replace(/-/g,'/'))
	const y = dt.getFullYear()
	const m = (dt.getMonth() + 1 + '').padStart(2, '0')
	const d = (dt.getDate() + '').padStart(2, '0')
	//padStart(2,'0') 意思是不足两位自动补0
	const hh = (dt.getHours() + '').padStart(2, '0')
	const mm = (dt.getMinutes() + '').padStart(2, '0')
	const ss = (dt.getSeconds() + '').padStart(2, '0')
	return `${y}-${m}-${d}`
})
Vue.prototype.audioplay = function(path){
	const innerAudioContext = uni.createInnerAudioContext();
	innerAudioContext.autoplay = true;
	innerAudioContext.src = path;
	innerAudioContext.onPlay(() => {
	  console.log('开始播放');
	});
	innerAudioContext.onEnded(() => {
	innerAudioContext.stop()
	 console.log('播放结束!');
	
	 })
	innerAudioContext.onError((res) => {
	  console.log(res.errMsg);
	  console.log(res.errCode);
	});
}
Date.prototype.format = function(format) {
	var o = {
		"M+": this.getMonth() + 1, //month
		"d+": this.getDate(), //day
		"h+": this.getHours(), //hour
		"m+": this.getMinutes(), //minute
		"s+": this.getSeconds(), //second
		"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
		"S": this.getMilliseconds() //millisecond
	}
	if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
		(this.getFullYear() + "").substr(4 - RegExp.$1.length));
	for (var k in o)
		if (new RegExp("(" + k + ")").test(format))
			format = format.replace(RegExp.$1,
				RegExp.$1.length == 1 ? o[k] :
				("00" + o[k]).substr(("" + o[k]).length));
	return format;
}
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif